**** Git Version Control ***** Init git config --global user.name "Jess Bugs" git config --global user.email jessbaggzz35@gmail.com Default branch git config --global init.default branch master Help git config -h Create a repo: git init Rename a brach git branch -m old-branch-name new-branch-name Track files: git add index.html Track entire dir git add . Check status git status Untrack files git rm --cached index.html Ignore a file nano .gitignore include the filename to be ignored: index.html Commit git commit -m "your initial commit message" See modification/changes git diff After making changes to a file, you added it to staging (tracked files), then want put back to "working environment" (remove from staging): git restore --staged index.html Bypass "staging" environment and commit directly: git commit -a -m "second commit" Restore a file that is being tracked in working directory: git restore index.html Check commit history git log Abbreviated: git log --oneline Amend last commit git commit -m "modify message of last commit" --amend See commit history in detail: git log -p Revert to a specific commit (snapshot) git reset --hard [commit hash] Note: this will overwrite your working directory files with the previous commit files After doing a --hard reset, all commits will be unreachable. To show the "disappeared" commits: git reflog Then: git reset --hard [commit hash] Checking out (detached head - Look Around) git checkout [commit hash] To go back: git checkout [branch name] Create a new branch git branch NewBranch List Branches git branch Switch to branch git switch NewBranch Merging branches git merge -m "Fixed bug" NewBranch Delete a branch git branch -d NewBranch Create and switch to a new branch git switch -c NewBranch STASHING: Stash the current progress: git stash git stash save "message for current progress" List stashes: git stash list At this point, you can switch (checkout) to other branches without committing the current progress on this branch. When you return to this branch, apply the stashed changes with: Apply Stash git stash apply git stash apply stash@{n} Drop a stash git stash drop stash@{n} Pop and apply stash git stash pop Remove (clear) all stashes git stash clear Git from W3SHOOLS Check remote (origin) commit history: git log origin/main --oneline List all local and remote branches git branch -a Create a new branch git checkout -b new-branch Push a branch to remote repository git push origin new-branch